package com.dubbo.consumer;

import com.dubbo.consumer.Annotation.Config.ConsumerConfiguration;
import com.dubbo.consumer.Annotation.ConsumerAnnotationService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.io.IOException;

/**
 * 注解方式启动
 *
 */
//@EnableDubbo
public class AppAnnotation {
    public static void main( String[] args ) throws IOException {

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start(); // 启动
        ConsumerAnnotationService consumerAnnotationService = context.getBean(ConsumerAnnotationService.class);
        String hello = consumerAnnotationService.doSayHello("annotation"); // 调用方法
        System.out.println("result: " + hello); // 输出结果

        for(int i=0;i<10;i++)
        {
            //Hystrix 服务降级测试
            String hellot = consumerAnnotationService.doSayHelloHystrix("annotationHystrix"); // 调用方法
            System.out.println("result: " + hellot); // 输出结果
        }

        System.in.read();
    }
}
